Week 09: Output Devices

Energy and output devices

This week's topic was Output Devices. We explored how energy is converted into motion (motors), light (LED diodes), and sound (pressure sensors). We learned about different types of motors (DC motors and MOSFETs, stepper motors, servo motors).

To understand this topic, it is important to grasp the following fundamentals.

Charge

Electrical charge is a property of particles like electrons and protons. Electrons carry a negative charge and protons a positive one. These charges are the reason why electric current can occur when they move.

Voltage

Voltage is a measure of how strongly electrons are "pushed" or "pulled" in a circuit. It can be thought of similarly to the pressure in a water pipe, determining how fast the water can flow. Higher voltage means more "pressure" is applied to move electrons through a conductor.

Current

Current refers to the amount of electrons flowing through a conductor like a wire. The unit for measuring current is the ampere. A stronger current means more electrons are flowing through the wire.

Ohm's Law

Ohm's Law illustrates the relationship between voltage, current, and resistance in an electric circuit. It states that the voltage is equal to the product of current and resistance. If the resistance remains constant, an increase in voltage leads to an increase in current. This law helps in understanding how different components in a circuit work together.

Electromagnetism

Electromagnetic forces are fundamentally important for virtually all modern technologies, including electronics, communication, and electric motors. The interaction between current and magnetism generates motion. Whenever there is a current, there is also an electromagnetic field. The larger it is, the more it can move things - allowing movement in different directions by changing the flow of the current.

Motors

DC MOTORS are electrical motors characterized by their simple construction and versatility. They convert electrical energy into mechanical motion.

A MOSFET is a special type of switch in electronics. It is used to turn electricity on and off or to regulate it. It is controlled by voltage. These switches are very useful and are found in many devices from computers to cars.

A STEPPER MOTOR, also called a stepping motor, is a special type of electric motor that can be divided into precise steps to allow for accurate movements and positioning. Each step corresponds to a small rotational movement, enabling very precise control of the motor's motion

A SERVO MOTOR is a small, powerful motor capable of precise position control. It combines a motor with a position feedback sensor and a control unit. Servo motors can be controlled with Arduino.

Signal Types:

  • digitalWrite is a command in many programming languages like Arduino, used to set a digital pin to a specific state. With this command, you can tell a pin to be either "HIGH" (on) or "LOW" (off).
  • HIGH: "HIGH" is a state corresponding to an "on" or "active" condition. When a pin is set to "HIGH," it typically has operating voltage, which corresponds to the logic level "1," and the pin outputs a voltage close to the microcontroller's supply voltage (e.g., 5V or 3.3V).
  • LOW: "LOW" is the opposite of "HIGH" and represents an "off" or "inactive" state. When a pin is set to "LOW," it is grounded, typically 0 volts, considered as the logic level "0."

Touchpad with SAMD11

Since I had already programmed my SAMD11 board the previous week, I only needed to modify the code. I wanted to change the code so that the LED would light up only when one of the touchpads is touched. Therefore, I continued to use the LED and included pins 5, 14, and 15 (analog Pins), to which the touch surfaces are connected.

First I defined my Pins:

  • #define PIN 5
  • #define PIN2 14
  • #define PIN3 15
  • #define LED 31

Then I defined Pin, Pin2, and Pin3 as INPUT_PULLUP and the LED as an OUTPUT. Finally, I defined that if the analog read of Pin, Pin2, and Pin3 is equal to or higher than 900, the LED should be HIGH, otherwise LOW. I determined the value of 900 by pressing on the pads to read the touch sensitivity.

Arduino

To try out a bit more, I looked for another project. Since I want to work with sound in my final project, I tried the Light Theremin project from the Arduino project book. In this project, a light sensor and a piezo are connected in such a way that the tone produced by the piezo changes depending on the light intensity.

Here are the steps I followed:

  1. I connected the breadboard to GND and 5V on the Arduino
  2. Piezo element: I connected one element to the ground and the other element to digital Pin 8.
  3. Light sensor: I connected the longer pin to the power supply, the shorter pin to analog Pin 0, and also to GND

Next, I had to write the program in the Arduino. First, I created variables for the highest and lowest sensor readings: sensorLow = 1023, sensorHigh = 0. Then, I defined the LED pin as 13. I set the LED pin as an OUTPUT and used digitalWrite to set it HIGH. Using a while loop, there is an opportunity to calibrate the sensor by running it in a loop for the first 5 seconds. The initially stated sensor values are then updated. In the loop, the readings from the analog input are taken. I then set sensorLow at 50 and sensorHigh at 4000. Using the tone function (Pin 8), tones are now generated that are determined by the pitch. Depending on the brightness the light sensor detects, the tone changes. In the example, I changed the brightness over the light sensor with my hand.

Group assignment

On this page, you will find all the information regarding to our group assignment.